package com.xiaoma.boot;

import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

/**
 * @author maj
 * @ClassName SpringClient
 * @Description
 * @date 2020-10-08 11:29
 */
public class SpringClient {

  public static void main(String[] args) {
    Resource resource=new ClassPathResource("applicationContext.xml");
    DefaultListableBeanFactory defaultListableBeanFactory = new DefaultListableBeanFactory();
    BeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(
        defaultListableBeanFactory);

    beanDefinitionReader.loadBeanDefinitions(resource);
    Student student = (Student)defaultListableBeanFactory.getBean("student");
    System.out.println(student.getName());

  }
}
